'use strict';

const Controller = require('egg').Controller;

class CartController extends Controller {
  async index() {
    const { ctx } = this;
    var {userName} = ctx.request.query
    var db = this.app.mongodb;
    var res = await db.collection('user-cart').find({userName}).toArray();
    if(res.length){
      ctx.body = res
    }else{
      ctx.body = "输入的用户名不正确"
    }
  }
}

module.exports = CartController;
